package com.mec.web.y2012.coreservlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.mec.beans.y2012.coreservlet.CompanyBean;
import com.mec.beans.y2012.coreservlet.EmployeeBean;
import com.mec.beans.y2012.coreservlet.NameBean;

@WebServlet("/BeanPropertiesServlet")
public class BeanPropertiesServlet extends HttpServlet {
	private static final long serialVersionUID = 8536580404821985768L;
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		NameBean name = new NameBean("Marty", "Hall");
		CompanyBean company = new CompanyBean("coreservlets.com", "J2EE Training and Consulting");
		
		EmployeeBean employee = new EmployeeBean(name, company);
		req.setAttribute("employee", employee);
		//
		RequestDispatcher dispatcher = req.getRequestDispatcher("el/bean-properties.jsp");
		dispatcher.forward(req, resp);
		
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}


	private static final Logger logger = 
			Logger.getLogger(BeanPropertiesServlet.class);

}
